<?php

namespace app\service\shopify\action\store;

use app\service\shopify\ShopifyApiService;

class CartStore extends ShopifyApiService
{
    /**
     * @param array $input
     * @return array|string|null
     * @doc https://shopify.dev/docs/api/storefront/latest/mutations/cartcreate
     * @desc 创建购物车
     */
    public function createCart(array $input)
    {
        $query = <<<QUERY
mutation cartCreate(\$input: CartInput) {
  cartCreate(input: \$input) {
    cart {
      id,
      checkoutUrl
    }
    userErrors {
      field
      message
    }
    warnings {
     code
     message
    }
  }
}
QUERY;
        return $this->send($query,compact('input'));
    }
}
